package lc;

import java.util.*;

public class Ex91 {
    class Solution {
        public int numDecodings(String s) {
            char[] cs = s.toCharArray();
            if (cs[0] == '0') return 0;
            int len = cs.length, tmp;
            int[] f = new int[len];
            // new String(1);
            // Queue<Integer> queue = new PriorityQueue<>((n1, n2) -> new String(n2).compareTo(new String(n1)));
            f[0] = 1;
            Queue<Integer> queue = new PriorityQueue<>((n1, n2) -> (n2 + "").compareTo(n1 + ""));
            for (int i = 1; i < len; i++) {
                if (cs[i] == '0') {
                    if (cs[i - 1] == '0' || cs[i - 1] > '2')
                        return 0;
                    else f[i] = f[i - 1];
                } else {
                    tmp = (cs[i - 1] - '0') * 10 + cs[i] - '0';
                    if (tmp > 26) {
                        f[i] = f[i - 1];
                    } else {
                        f[i] = f[i - 1] + 1;
                    }
                }
            }
            return f[len - 1];
        }
    
    
        // public void
    
    }
}
